package com.nnxy.worktostudy.utils;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author : lu'qz
 * @create 2021/9/22 17:45
 */
@Accessors(chain = true)      //开启链式编程
@Data
public class ResponseFormat {
    private Boolean success;
    private Integer code;
    private String message;
    private Map<String, Object> data = new HashMap<>();

    private ResponseFormat(){};

    public static ResponseFormat succeed() {
        ResponseFormat r = new ResponseFormat();
        r.setSuccess(true);
        r.setCode(2000);
        r.setMessage("访问成功!");
        return r;
    }

    public static ResponseFormat failed() {
        ResponseFormat r = new ResponseFormat();
        r.setSuccess(false);
        r.setCode(2001);
        r.setMessage("访问失败!");
        return r;
    }
}
